package com.xuyuan.agent.intro;

public class ProxyOrder1Service implements OrderService {

    // 被代理的对象
    private OrderService orderService;

    public ProxyOrder1Service(OrderService orderService) {
        this.orderService = orderService;
    }

    // 执行
    public static void main(String[] args) {
        // 创建被代理对象
        OrderService orderService = new OrderServiceImpl();

        // 创建代理对象
        ProxyOrder1Service proxy = new ProxyOrder1Service(orderService);

        proxy.save();
    }

    @Override
    public void save() {
        System.out.println("代理前置处理 ...");
        // 执行被代理的对象的方法
        orderService.save();
        System.out.println("代理后置处理 ...");
    }
}
